<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.beaut.project.util.FlowUtility" %>
<%@ page import="com.beaut.project.util.StaticData" %>
<%@ include file="/public/header.jsp"%>
<%
    String callback = request.getParameter("callback");
	String flagType = request.getParameter("flagType") == null ? "" : request.getParameter("flagType");
	Map<String, Object> sessionMap = (Map<String, Object>) session.getAttribute("LOGIN_USER");
	String person_id = String.valueOf(sessionMap.get("id"));
	String person = String.valueOf(sessionMap.get("truename"));
%>
<html>
	<head>
		<title>工单选择</title>
			<link href="<%=contextPath%>/public/css/smart_wizard_vertical.css" rel="stylesheet"	type="text/css">
		<script type="text/javascript" src="<%=contextPath%>/public/js/jquery.smartWizard.js"></script>
		<link  rel="stylesheet"  href  ="<%=contextPath%>/public/swfupload/css/swfupload.css">
	
	<script type="text/javascript">
	$(function(){
		$("#searchValue").keypress(function(e) { 
	    	// 回车键事件 
	     	if(e.which == 13) { 
	     		 doSearch();
	       	} 
	   	}); 
		$("#table").datagrid({
			title:"工单管理",
			iconCls:'icon-edit',
			loadMsg:'正在加载数据，请稍后......',
			url:'<%=contextPath %>/springMVC/gd/listGd?flagType=<%=flagType%>',
			rownumbers:true,
			singleSelect:true,
			fitColumns:true,
			nowrap:false,
			idField:'id',
			frozenColumns:[[
			    {title:'主键',field:'id',hidden:true},
			    {title:'项目id',field:'xm_id',hidden:true},
			    {title:'项目编号',field:'xm_code',hidden:true},
			    {title:'项目名称',field:'xm_name',hidden:true},
			    {title:'客户id',field:'customer_id',hidden:true},
			    {title:'客户',field:'customer',hidden:true},
			    {title:'所属部门id',field:'dept_id',hidden:true},
			    {title:'所属部门',field:'dept_name',hidden:true},
			    {title:'工单内容id',field:'gd_content_id',hidden:true},
			    {title:'班组id',field:'gd_worker_id',hidden:true},
			    {title:'班组',field:'gd_worker_name',hidden:true}
			]],
			columns:[[
				{title:'工单状态',field:'gd_status',hidden:true},
				{title:'工单状态',field:'gd_status_desc',width:100,align:'center'},
				{title:'工单编号',field:'gd_code',width:100,align:'center'},
				{title:'工单名称',field:'gd_name',width:200,align:'center'},
				{title:'创建日期',field:'gd_create_time',width:200,align:'center'},
				{title:'查看详情',field:'more',width:50,align:'center',formatter:function(value,rowData,rowIndex){
                    return "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='工单详情' onclick=\"javascript:viewData('"+rowData.id+"','"+rowData.gd_content_id+"');\"/>";
				}},
				{title:'选择操作',field:'chose',width:50,align:'center',formatter:function(value,rowData,rowIndex){
					return "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-ok' title='选择此工单' onclick=\"javascript:choseGd('"+rowData.id+"','"+rowData.gd_code+"','"+rowData.gd_name+"','"+rowData.dept_id+"','"+rowData.dept_name+"','"+rowData.customer_id+"','"+rowData.gd_worker_id+"','"+rowData.gd_worker_name+"');\"/>";
				}}
			]],
			pageSize:10,
			pageList : [10,50,100],  
			pagination:true,
			onLoadSuccess:function(rtJson){
				if(rtJson.rtState== '1')
				{
					$.messager.alert('提示',rtJson.rtMsrg);
				}
			},toolbar:"#tb",
		onDblClickRow:function(rowIndex, rowData){
			choseGd(rowData.id,rowData.gd_code,rowData.gd_name,rowData.dept_id,rowData.dept_name,rowData.customer_id);
		}
		});
	});
		function  viewData(gd_id,gd_content_id){
			openDialogResize("<%=contextPath %>/springViews/gd/showGd.jsp?gd_id="+gd_id+"&gd_content_id="+gd_content_id+"&callback=rtCallBack",1000, 800);
		}
		
		function rtCallBack(){
			$('#table').datagrid('reload');
		}
		function choseGd(gd_id,gd_code,gd_name,dept_id,dept_name,customer_id,gd_worker_id,gd_worker_name){
				window.opener.rtCallBackGD(gd_id,gd_code,gd_name,dept_id,dept_name,customer_id,gd_worker_id,gd_worker_name);
				window.close();
		}

		function doSearch()
		{
			var start_time=$('#start_time').datebox('getValue');  
			var end_time=$('#end_time').datebox('getValue');  
			var searchValue = $('#searchValue').val();
			$('#table').datagrid('load',{
				searchValue:searchValue,
				start_time:start_time,
				end_time:end_time
				
			});
		}
		
	</script>
	</head>
	<body style="height: 97%">
	<div id="table" data-options="fit:true" ></div>
		<div id="tb" style="padding:3px;height:auto">
			<div style="float:left;">
			</div>
			<div align="right">
				开始时间：<input id="start_time" name="start_time" class="easyui-datebox" />&nbsp;&nbsp;&nbsp;结束时间：<input id="end_time" name="end_time" class="easyui-datebox" />
								工单编号/名称：<input id="searchValue" name="searchValue" style="width:150px" title="项目名称或编码" />&nbsp;&nbsp; 
				<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="doSearch();"></a>
			</div>
		</div>
</html>